from django.urls import path, include
from django.conf.urls import url
from django.views.static import serve

import extra_apps.xadmin

from apps.users.views import *
from apps.operations.views import *
from apps.courses.views import *
from apps.organizations.views import *
from WeiJi.settings import MEDIA_ROOT

# 路由配置
urlpatterns = [
    # 管理员：
    path('xadmin/', extra_apps.xadmin.site.urls),
    # 图片验证码插件
    path('captcha/', include('captcha.urls')),
    # 首页：
    path('', Index.as_view(), name="index"),
    path('index/', Index.as_view(), name="index"),
    # 用户
    url(r'^users/', include(('apps.users.urls', "users"), namespace="users")),
    path('login/', LoginView.as_view(), name="login"),
    path('register/', RegisterView.as_view(), name="register"),
    path('logout/', LogoutView.as_view(), name="logout"),
    # 课程相关：
    url(r'^courses/', include(('apps.courses.urls', "course"), namespace="courses")),
    # 机构相关：
    url(r'^org/', include(('apps.organizations.urls', "organizations"), namespace="org")),
    # 用户相关操作
    url(r'^op/', include(('apps.operations.urls', "operations"), namespace="op")),
    # 媒体资源
    url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}),

]
